<template>
	<view>
		<view class="headBox">
			<text class="wzText">个人</text>
		</view>
		<view class="conbox">
			<view class="box1">
				<view class="head-img" @click="toInfo">
					<image :src="path+userInfo.avatar"></image>
					<view class="userName">{{userInfo.realName}}</view>
					<view class="phone">{{userInfo.phone}}</view>
				</view>
				<view class="possw-view" @click="getItem(1)">
					<view>修改密码</view>
					<view>
						<uni-icons type="right" size="20"></uni-icons>
					</view>
				</view>
				<view class="possw-view" v-if="userInfo.roleId==3" @click="getItem(2)">
					<view>我的账户 </view>
					<view>
						<uni-icons type="right" size="20"></uni-icons>
					</view>
				</view>
				<view class="possw-view" @click="getItem(3)">
					<view>我的二维码</view>
					<view>
						<uni-icons type="right" size="20"></uni-icons>
					</view>
				</view>
				<view class="possw-view" @click="getItem(4)">
					<view>项目核销</view>
					<view>
						<uni-icons type="right" size="20"></uni-icons>
					</view>
				</view>
				<view class="possw-view" @click="getItem(5)">
					<view>退出登录</view>
					<view>
						<uni-icons type="right" size="20"></uni-icons>
					</view>
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	export default {

		data() {
			return {
				path: this.$http.tpUrl + '/', // 图片前缀
				userInfo: {}
			}
		},
		onLoad() {

		},
		onShow() {
			this.userInfo = JSON.parse(uni.getStorageSync('user_info'));
			console.log("userInfo", this.userInfo,this.userInfo.id,this.userInfo.roleId);
			 
		},
		onReachBottom() {
			// 触底分页
			console.log('触底')
			// if (this.total > this.list.length) {
			// 	this.page = parseInt(this.page) + 1
			// }
		},     
		methods: {
			// 去头像信息
			toInfo() {
				uni.navigateTo({
					url: `/pages_category_page1/mine/userInfo`
				})
			},
			toDetails(item) {
				if (item.title == '我的订单') {
					uni.switchTab({
						url: item.path
					})
					return
				}
				uni.navigateTo({
					url: item.path
				})
			},
			 
			// 改密码
			getItem(index) {
				let id = 1
				let paramsStr = `?id=${id}`
				
				
				var url="";
					
				if(index==1){
					url=`/pages_category_page1/mine/changePassword${paramsStr}`;
				}
				if(index==2){
					url=`/pages_category_page1/mine/myAccount${paramsStr}`;
				}
				if(index==3){
					url=`/pages_category_page1/mine/QRCode${paramsStr}`;
				}
				if(index==4){
					url=`/pages_category_page1/mine/checkProject${paramsStr}`;
				}
				if(index==5){
				uni.removeStorageSync('user_info');
					 url=`/pages/login/login`;
				}
				console.log("url",url)
				uni.navigateTo({
					url: url
				})
			},


		}
	}
</script>

<style scoped>
	.headBox {
		font-size: 36rpx;
		font-family: Microsoft YaHei, Microsoft YaHei-Bold;
		font-weight: 700;
		text-align: center;
		color: #232323;
		padding-top: 88rpx;
		padding-left: 30rpx;
		padding-right: 30rpx;
		padding-bottom: 112rpx;
		background: linear-gradient(89deg, #f9d7a6 1%, #ffdc95 100%);
	}

	.headBox .wzText {
		line-height: 56rpx;
	}

	.conbox {
		padding: 0 30rpx;
		margin-top: -90rpx;
	}

	.box1 {
		background: #ffffff;
		border-radius: 10rpx;
		box-shadow: 0rpx 2rpx 6rpx 0rpx rgba(93, 69, 41, 0.25);
		padding: 40rpx 30rpx;
	}

	.head-img {
		padding-left: 106rpx;
		position: relative;
	}

	.head-img image {
		width: 84rpx;
		height: 84rpx;
		border-radius: 50%;
		position: absolute;
		top: 0;
		left: 0;
		background: #999;
	}

	.userName {
		font-size: 28rpx;
		font-family: Microsoft YaHei, Microsoft YaHei-Bold;
		font-weight: 700;
		color: #5d4529;
	}

	.phone {
		font-size: 24rpx;
		font-family: Microsoft YaHei, Microsoft YaHei-Regular;
		font-weight: 400;
		color: #5d4529;
		margin-top: 11rpx;
	}

	.possw-view {
		display: flex;
		margin-top: 56rpx;
		margin-bottom: 5rpx;

	}

	.possw-view>view {
		flex: 1;
	}

	.possw-view>view:nth-child(2) {
		text-align: right;
	}
</style>